package edu.dayu.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.dayu.mapper.ClubPersonMapper;
import edu.dayu.pojo.ClubPerson;
import edu.dayu.service.ClubPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClubPersonServiceImpl implements ClubPersonService {
    @Autowired
    private ClubPersonMapper clubPersonMapper;

    @Override
    public PageInfo<ClubPerson> clubPersonList(ClubPerson clubPerson) {
        PageHelper.startPage(clubPerson.getPageNum(),clubPerson.getPageSize());
        List<ClubPerson> clubPeople = clubPersonMapper.clubPersonList(clubPerson);
        PageInfo<ClubPerson> personPageInfo = new PageInfo<>(clubPeople);
        return personPageInfo;
    }

    @Override
    public void clubPersonInsert(ClubPerson clubPerson) {
        clubPersonMapper.clubPersonInsert(clubPerson);
    }

    @Override
    public void clubPersonUpdate(ClubPerson clubPerson) {
        clubPersonMapper.clubPersonUpdate(clubPerson);
    }

    @Override
    public void clubPersonDelete(ClubPerson clubPerson) {
        clubPersonMapper.clubPersonDelete(clubPerson);
    }

    @Override
    public void clubPersonMultiInsert(List<ClubPerson> clubPersonList, String c_id) {
        for (ClubPerson clubPerson : clubPersonList) {
            clubPerson.setC_id(new Integer(c_id));
        }
        clubPersonMapper.clubPersonMultiInsert(clubPersonList);
    }
}
